guint refcount;
OstreeFetcher *self;
SoupURI *uri;
+ int priority;
OstreeFetcherState state;
GSimpleAsyncResult *result;
} OstreeFetcherPendingURI;
+static int
+pending_uri_compare (gconstpointer a,
+ gconstpointer b,
+ gpointer unused)
+{
+ const OstreeFetcherPendingURI *pending_a = a;
+ const OstreeFetcherPendingURI *pending_b = b;
+
+ return (pending_a->priority == pending_b->priority) ? 0 :
+ (pending_a->priority < pending_b->priority) ? -1 : 1;
+}
+
static void
pending_uri_free (OstreeFetcherPendingURI *pending)
{
SoupURI *uri,
gboolean is_stream,
guint64 max_size,
+ int priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data,
pending->self = g_object_ref (self);
pending->uri = soup_uri_copy (uri);
+ pending->priority = priority;
pending->max_size = max_size;
pending->is_stream = is_stream;
pending->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
}
pending->out_tmpfile = out_tmpfile;
- g_queue_push_tail (&self->pending_queue, pending);
+ g_queue_insert_sorted (&self->pending_queue, pending, pending_uri_compare, NULL);
ostree_fetcher_process_pending_queue (self);
}
_ostree_fetcher_request_uri_with_partial_async (OstreeFetcher *self,
SoupURI *uri,
guint64 max_size,
+ int priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- ostree_fetcher_request_uri_internal (self, uri, FALSE, max_size, cancellable,
+ ostree_fetcher_request_uri_internal (self, uri, FALSE, max_size, priority, cancellable,
callback, user_data,
_ostree_fetcher_request_uri_with_partial_async);
}
ostree_fetcher_stream_uri_async (OstreeFetcher *self,
SoupURI *uri,
guint64 max_size,
+ int priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- ostree_fetcher_request_uri_internal (self, uri, TRUE, max_size, cancellable,
+ ostree_fetcher_request_uri_internal (self, uri, TRUE, max_size, priority, cancellable,
callback, user_data,
ostree_fetcher_stream_uri_async);
}
ostree_fetcher_stream_uri_async (fetcher, uri,
max_size,
+ OSTREE_FETCHER_DEFAULT_PRIORITY,
cancellable,
fetch_uri_sync_on_complete, &data);
#define OSTREE_IS_FETCHER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), OSTREE_TYPE_FETCHER))
#define OSTREE_FETCHER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), OSTREE_TYPE_FETCHER, OstreeFetcherClass))
+/* Lower values have higher priority */
+#define OSTREE_FETCHER_DEFAULT_PRIORITY 0
+
typedef struct OstreeFetcherClass OstreeFetcherClass;
typedef struct OstreeFetcher OstreeFetcher;
void _ostree_fetcher_request_uri_with_partial_async (OstreeFetcher *self,
SoupURI *uri,
guint64 max_size,
+ int priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
_ostree_fetcher_request_uri_with_partial_async (pull_data->fetcher, obj_uri,
expected_max_size,
+ OSTREE_FETCHER_DEFAULT_PRIORITY,
pull_data->cancellable,
is_meta ? meta_fetch_on_complete : content_fetch_on_complete, fetch_data);
soup_uri_free (obj_uri);
target_uri = suburi_new (pull_data->base_uri, deltapart_path, NULL);
_ostree_fetcher_request_uri_with_partial_async (pull_data->fetcher, target_uri, size,
+ OSTREE_FETCHER_DEFAULT_PRIORITY,
pull_data->cancellable,
static_deltapart_fetch_on_complete,
fetch_data);